package com.itheima.jingjie.map.练习3;

import java.util.*;

/*1.6.3集合嵌套之ArrayList嵌套HashMap
案例需求
创建一个ArrayList集合，存储三个元素，每一个元素都是HashMap
每一个HashMap的键和值都是String，并遍历。*/
public class Demo1 {
    public static void main(String[] args) {
        ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> map1 = new HashMap<String, String>();
        HashMap<String, String> map2 = new HashMap<String, String>();
        HashMap<String, String> map3 = new HashMap<String, String>();
        Collections.addAll(list, map1, map2, map3);
        map1.put("唐僧", "38");
        map1.put("悟空", "38");
        map1.put("八戒", "38");
        map1.put("沙僧", "38");
        map1.put("白龙马", "38");

        map1.put("贾宝玉", "18");
        map1.put("贾夫人", "38");
        map1.put("贾宝钗", "18");
        map1.put("贾老爷", "28");

        map1.put("宋江", "38");
        map1.put("晁盖", "35");
        map1.put("林冲", "28");
        map1.put("武松", "25");
        map1.put("吴用", "30");
        for (HashMap<String, String> hashMap : list) {
            hashMap.forEach((s1, s2) ->
                    System.out.print(s1 + "..." + s2 + "  "));

        }
    }
}
